﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Serious
{
    public struct MouseEvent
    {
        public MouseState Current;
        public MouseState Previous;

        public MouseEvent(MouseState current, MouseState previous)
        {
            Current = current;
            Previous = previous;
        }

        public Index2 Location
        {
            get
            {
                return new Index2(Current.X, Current.Y);
            }
        }

        public float ScrollAmt
        {
            get
            {
                // i hate you microsoft. seriously. so freaking much. possibly even more than
                // flixel, and that's saying something.
                // it's not just XNA that i hate; not just winders either, but ALL OF MICROSOFT
                // biggest. idiots. ever
                return (float)(Current.ScrollWheelValue - Previous.ScrollWheelValue) / 120.0f;
            }
        }

        public bool IsButtonDown(Mbtn button)
        {
            return Current.IsButtonDown(button);
        }
        public bool IsButtonUp(Mbtn button)
        {
            return Current.IsButtonUp(button);
        }

        public bool WasButtonPressed(Mbtn button)
        {
            return Current.IsButtonDown(button) && !Previous.IsButtonDown(button);
        }
        public bool WasButtonReleased(Mbtn button)
        {
            return Current.IsButtonUp(button) && !Previous.IsButtonUp(button);
        }
    }
}
